package com.wanmait.happyheating.util;

import java.io.Serializable;

public class Result implements Serializable {
    private Boolean success;
    private Integer code;
    private String message;
    private Object data;


    public Result(ResultCode resultCode)
    {
        this.success = resultCode.success;
        this.code = resultCode.code;
        this.message = resultCode.message;
    }
    public Result(ResultCode resultCode,Object data){
        this(resultCode);
        this.data = data;
    }
    public Result(Boolean success,Integer code,String message){
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public static Result success(){
        return new Result(ResultCode.SUCCESS);
    }
    public static Result success(Object data){
        return new Result(ResultCode.SUCCESS,data);
    }
    public static Result success(String message){
        ResultCode.SUCCESS.message = message;
        return new Result(ResultCode.SUCCESS);
    }
    public static Result success(String message,Object data){
        ResultCode.SUCCESS.message=message;
        return new Result(ResultCode.SUCCESS,data);
    }
    public static Result error(){
        return new Result(ResultCode.ERROR);
    }
    public static Result error(Object data){
        return new Result(ResultCode.ERROR,data);
    }
    public static Result error(String message)
    {
        ResultCode.ERROR.message = message;
        return new Result(ResultCode.ERROR);
    }

    public static Result fail(){
        return new Result(ResultCode.FAIL);
    }
    public static Result fail(Object data){
        return new Result(ResultCode.FAIL,data);
    }

    public static Result fail(String message)
    {
        ResultCode.FAIL.message=message;
        return new Result(ResultCode.FAIL);
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
